package com.czy;

import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.List;

public class 导入钱江考勤用户 {
    public static void main(String[] args) throws IOException {
        File file = new File("F:\\OneDrive\\Desktop\\无标题.json");

        BufferedReader br = new BufferedReader(new FileReader(file));
        String s;
        StringBuilder stringBuilder = new StringBuilder();
        while ((s = br.readLine()) != null) {
            stringBuilder.append(s);
        }
        JSONArray parse = JSONArray.parseArray(stringBuilder.toString());
        List<JSONObject> list = parse.toList(JSONObject.class);

        StringBuilder sb = new StringBuilder();
        sb.append("insert into sys_user (user_id,dept_id,user_name,nick_name,sex,work_code,zw,phonenumber) values ");
        for (JSONObject jsonObject : list) {
            sb
                    .append("(")
                    .append(jsonObject.get("ehr_id")).append(",")
                    .append(jsonObject.get("ssbm")).append(",")
                    .append("'").append(jsonObject.get("gh")).append("'").append(",")
                    .append("'").append(jsonObject.get("xm")).append("'").append(",")
                    .append("'").append(jsonObject.getInteger("xb") - 1).append("'").append(",")
                    .append("'").append(jsonObject.get("gh")).append("'").append(",")
                    .append("'").append(jsonObject.get("gw")).append("'").append(",")
                    .append("'").append(jsonObject.get("sjh")).append("'")
                    .append("),");
        }
        System.out.println(sb);

    }
}
